<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的</title>
    <link rel="stylesheet" type="text/css" href="../css/page/user.css" />
   
</head>

<body>
    <div class="page"  @vue:mounted="mounted">
        <div class="user_box">
            <img class="user_logo" :src='data.userInfo.avatar'  mode="aspectFill" />
            <div class="user_wrap" v-if="data.isLogin"  @click="gotouserSetting( )">
                <span class="user_name" >{{data.userInfo.name}} <button>实名认证</button>  </span>
                <!-- <span>游客号：448732134</span> -->
                <span>登录号：{{data.userInfo.mobile}}</span>
            </div>

            <div class="user_wrap" v-else>
                <span class="user_name" >你好, <button @click="loginNow">请登录</button>  </span>
                <!-- <span>游客号：---</span> -->
                <span>登录号：---</span>
           
            </div>

        </div>

        <div class="key-enter" >
            <div class="amount-deg">
                <span class="amount">0.00</span>
                <span class="btn-nor">门票余额</span>
               
            </div>
            <div class="active-deg">
                <span class="amount">0</span>
                <span class="btn-nor">活跃度</span>  
            </div>
        </div>

        <div class="mine-ad" ></div>

        <ul class="sub-menu" >
            <li class="menu">
                <span class="icon-one"></span>
                奖励大厅
            </li>
            <li class="menu">
                <span class="icon-two"></span>
                转赠
            </li>
            <li class="menu">
                <span class="icon-three"></span>
                邀请好友
            </li>
        </ul>

        <div class="my-service">
            <div class="stitle">我的服务</div>
            <ul class="service-list">
              
                    <li  @click="onItemClick(item)" v-for="item in data.serviceList" >
                        <div v-if="item.show">
                            <span :class="item.className" ></span>
                            {{item.name}}
                        </div>
                        
                    </li> 
               
                  
            </ul>
        </div>
    </div>
</body>
<script src="../script/api.js"></script>
<script src="../script/common.js"></script>

<script  type="module">
    import { createApp } from 'https://www.chenxiangle.com/app/web/script/pvue.js';
    const APP = ()=>{
        createApp({
        data:  { 
            testDisplay:false,
            pageadd:'',
            userInfo:{},
            isLogin:false,   // 是否登录成功
            serviceList:[{
                name:'设置',
                className:'sicon-one',
                kind:'setting',
                url:'usersetting.html',
                show:true
            },{
                name:'在线客服',
                className:'sicon-two',
                kind:'call',
                show:true
            },{
                name:'我的二维码',
                className:'sicon-three',
                url:'usersetting.html'
            },{
                name:'联盟链',
                className:'sicon-four',
                url:'usersetting.html'
            },{
                name:'靓号广场',
                className:'sicon-five',
                url:'usersetting.html'
            },{
                name:'获取验证码',
                className:'sicon-six',
                url:'usersetting.html'
            }]
        },
       
      onItemClick(item) {
            let  name = item.className;
            let url =  item.url;
            core.log(core.checklogin())
            if(url){
                api.openWin({
                    name,
                    url
                })
            }
            core.log(item.kind)
         if(item.kind=='call'){
            core.log(item)
            api.alert({
                  msg:'19926646797'
                });

         }
     
    },

  fnOrderList(item )  {
    if( core.checklogin() ){
        api.openWin({
            name: 'order_list',
            url:'./order_list.html',
            pageParam: { index: item  }
        })
    }
},
async  initUser(){
    let  res =  await core.user();
    core.log('user++++++++')
    if(res){ 
        this.data.userInfo = res.data;
        this.data.isLogin = true;
       
        core.log('重新调接口了 ')
     }else{
        core.log('退出了');
        this.data.isLogin = false;
        core.login();
     }
     if(this.data.userInfo && !this.data.userInfo.avatar) {
            this.data.userInfo.avatar = '../images/logo.png';
     }
},
   gotouserSetting(){
        if(core.checklogin()){
            let name ="edit";
            let url = "./useredit.html?action=edit";
            api.openWin({
                name,
                url
            })
        }
    },
    async getUserData(){
        let dt={};
        let res = await core.post("app/getUserData",dt);
        if(res!=undefined && res.pageadd!= undefined && res.pageadd.length>0){
            this.data.pageadd = res.pageadd; 
        }
    },
    loginNow(){
        core.login();
    },
    mounted() {
        window.app = this ;
        this.data.isLogin = core.checklogin();
       
        var frames = api.frames();
        core.log('frames')
        core.log(frames)
        if(this.data.isLogin) {
            this.initUser();
            this.getUserData();
        } else {
            core.login();
        }
    }
      }).mount()
    }

    window.apiready = ()=> {
        $api.fixStatusBar($api.dom('.nav-bar'));
        APP();
    }
</script>

 
</html>